* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Fira Sans', 'Droid Sans', 'Helvetica Neue', Arial, 'Noto Sans', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  background: #f6f7f9;
  color: #222;
}

.app {
  max-width: 1200px;
  margin: 40px auto;
  padding: 0 16px 40px;
}

h1 { font-weight: 700; margin: 0 0 16px; }

/* 顶部栏与字体选择器 */
.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.font-box { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.font-box label { font-size: 12px; color: #60656f; }
.font-box select {
  padding: 6px 10px;
  border: 1px solid #d6dae1;
  border-radius: 8px;
  background: #fff;
  font-size: 14px;
}
.font-advanced { display: flex; align-items: center; gap: 6px; }
.font-advanced input[type="url"], .font-advanced input[type="file"] {
  padding: 6px 8px;
  border: 1px solid #d6dae1;
  border-radius: 8px;
  background: #fff;
  font-size: 13px;
}
.font-advanced button {
  padding: 6px 10px;
  border: 1px solid #d6dae1;
  border-radius: 8px;
  background: #fff;
  font-size: 13px;
  cursor: pointer;
}
/* 左右布局 */
.content-grid {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 16px;
}
.pane.left { background: #fff; border: 1px solid #e6e8eb; border-radius: 10px; padding: 14px; }
.pane.right { }

@media (max-width: 960px) {
  .content-grid { grid-template-columns: 1fr; }
  .pane.left { order: 1; }
  .pane.right { order: 2; }
}

/* 新建任务表单 */
.new-todo { margin-bottom: 8px; }
.form-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  align-items: end;
}
.field label {
  display: block;
  margin: 0 0 6px;
  font-size: 12px;
  color: #60656f;
}
.field input, .field select, .field textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #d6dae1;
  border-radius: 8px;
  font-size: 14px;
  outline: none;
  background: #fff;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: #4c8bf5; box-shadow: 0 0 0 3px rgba(76,139,245,0.15);
}
/* 放大任务内容输入区域 */
.field.wide textarea {
  padding: 14px 16px;
  font-size: 16px;
  line-height: 1.5;
  min-height: 156px;
  resize: vertical;
  white-space: pre-wrap; /* 保留换行并自动换行 */
  word-break: break-word; /* 长单词或连续字符换行 */
}
.field.wide { grid-column: 1 / -1; }
.field.medium { grid-column: span 2; }
.field.small { grid-column: span 1; }
.actions-inline { grid-column: 4; justify-self: end; align-self: end; }
#add-btn {
  padding: 10px 14px;
  border: none;
  border-radius: 8px;
  background: #4c8bf5;
  color: #fff;
  font-size: 15px;
  cursor: pointer;
}

/* 列表控制 */
.controls {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 12px;
  align-items: center;
  margin: 0 0 8px;
}
.filters { display: flex; gap: 8px; }
.filter {
  padding: 6px 10px;
  border: 1px solid #d6dae1;
  border-radius: 20px;
  background: #fff;
  cursor: pointer;
}
.filter.active { background: #4c8bf5; color: #fff; border-color: #4c8bf5; }
.filters-advanced { display: flex; align-items: center; gap: 6px; }
.filters-advanced select { padding: 6px 10px; border: 1px solid #d6dae1; border-radius: 8px; background: #fff; }
.actions { display: flex; gap: 8px; justify-content: flex-end; }
#clear-completed {
  padding: 6px 10px; border: none; border-radius: 6px; background: #f03d5f; color: #fff; cursor: pointer;
}
#clear-completed:disabled { opacity: .5; cursor: not-allowed; }
#export-btn, #import-btn { padding: 6px 10px; border: 1px solid #d6dae1; border-radius: 6px; background: #fff; cursor: pointer; }

/* 列表 */
.todo-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid #e6e8eb; background: #fff; border-radius: 10px; }
.todo-item {
  display: grid;
  grid-template-columns: auto auto 1fr auto;
  align-items: start;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid #e6e8eb;
  transition: opacity .25s ease, transform .25s ease; /* 为淡出做准备 */
  will-change: opacity, transform;
}
.todo-item.leaving { opacity: 0; transform: translateY(-6px); pointer-events: none; }
.todo-item:last-child { border-bottom: none; }

.drag-handle { background: transparent; border: none; color: #b0b7c3; font-size: 18px; cursor: grab; padding: 0 4px; }
.drag-handle:active { cursor: grabbing; }
.todo-item.dragging { opacity: .6; }
.todo-item.drag-over { outline: 2px dashed #4c8bf5; outline-offset: -4px; }

.todo-item input.toggle { width: 18px; height: 18px; margin-top: 4px; }

.display .todo-text { font-size: 16px; line-height: 1.6; white-space: pre-wrap; word-break: break-word; }
.display .todo-text.completed { color: #9aa1ab; text-decoration: line-through; }

.item-meta { margin-top: 6px; color: #60656f; font-size: 13px; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 12px; background: #eef2ff; color: #3b5bdb; font-size: 12px; margin-right: 6px; }
.badge.type { background: #fff4e6; color: #d9480f; }
.badge.progress { background: #e6fcf5; color: #0ca678; }

.edit-btn, .delete-btn { background: transparent; border: none; color: #b0b7c3; font-size: 16px; cursor: pointer; }
.edit-btn:hover { color: #4c8bf5; }
.delete-btn:hover { color: #f03d5f; }

/* 编辑面板 */
.edit-panel { display: none; background: #f9fafb; border: 1px solid #e6e8eb; border-radius: 8px; padding: 10px; }
.todo-item.editing .display { display: none; }
.todo-item.editing .edit-panel { display: block; }

.edit-panel .row { display: flex; flex-wrap: wrap; gap: 8px; }
.edit-panel input[type="text"], .edit-panel select, .edit-panel textarea {
  padding: 10px 12px; border: 1px solid #d6dae1; border-radius: 6px; font-size: 15px; background: #fff;
}
/* 放大编辑面板中的“任务内容” */
.edit-panel .row .wide {
  flex: 1 1 420px;
  padding: 12px 14px;
  font-size: 16px;
  min-height: 156px;
  line-height: 1.5;
}
.edit-panel .row .medium { flex: 1 1 220px; }
.edit-panel .row .small { flex: 0 1 160px; }

.edit-actions { margin-top: 8px; display: flex; gap: 8px; }
.edit-actions .save { padding: 6px 10px; border: none; border-radius: 6px; background: #4c8bf5; color: #fff; cursor: pointer; }
.edit-actions .cancel { padding: 6px 10px; border: 1px solid #d6dae1; border-radius: 6px; background: #fff; cursor: pointer; }

.status { margin-top: 12px; color: #60656f; }

/* Accessibility */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.section { margin-top: 16px; background: #fff; border: 1px solid #e6e8eb; border-radius: 10px; padding: 10px; }
.section h3 { margin: 0 0 8px; font-size: 16px; }
.backup-controls { display: flex; gap: 8px; margin-bottom: 8px; }
.backup-list { list-style: none; margin: 0; padding: 0; }
.backup-list li { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-top: 1px solid #e6e8eb; }
.backup-list li:first-child { border-top: none; }
.backup-list .meta { color: #60656f; font-size: 13px; }
.backup-list .actions { display: flex; gap: 8px; }
.sync-form label { display: block; margin-bottom: 8px; color: #60656f; font-size: 12px; }
.sync-form input[type="url"], .sync-form input[type="password"] { width: 100%; padding: 8px 10px; border: 1px solid #d6dae1; border-radius: 8px; background: #fff; }
.sync-form .inline { display: flex; align-items: center; gap: 8px; margin: 8px 0; }
.sync-actions { display: flex; gap: 8px; }
.sync-status { margin-top: 8px; color: #60656f; font-size: 13px; }
.topbar { display:flex; align-items:center; justify-content:flex-end; margin: 6px 0 8px; }
.user-badge { display:inline-block; padding: 4px 8px; border:1px solid #e6e8eb; border-radius: 14px; font-size:12px; color:#60656f; background:#fff; }
.logout-btn { margin-left:8px; padding: 6px 10px; border:1px solid #d6dae1; border-radius: 6px; background:#fff; cursor:pointer; }

.login-overlay { position: fixed; inset: 0; background: linear-gradient(135deg, #eef2ff 0%, #fef9f3 100%); display: none; align-items: center; justify-content: center; padding: 24px; }
.login-overlay.show { display: flex; }
.login-card { width: 360px; max-width: 92vw; background: #fff; border: 1px solid #e6e8eb; border-radius: 16px; box-shadow: 0 20px 50px rgba(0,0,0,0.08); padding: 24px; }
.login-title { margin: 0 0 6px; font-size: 22px; font-weight: 700; }
.login-subtitle { margin: 0 0 16px; color: #60656f; }
.login-card label { display:block; font-size:12px; color:#60656f; margin:10px 0 6px; }
.login-card input[type="text"], .login-card input[type="password"] { width:100%; padding:10px 12px; border:1px solid #d6dae1; border-radius:8px; font-size:14px; outline:none; }
.login-card input:focus { border-color:#4c8bf5; box-shadow:0 0 0 3px rgba(76,139,245,0.15); }
.login-actions { display:flex; align-items:center; justify-content:space-between; margin-top:14px; }
#login-submit { padding: 10px 14px; border:none; border-radius:8px; background:#4c8bf5; color:#fff; font-size:15px; cursor:pointer; }

/* Toast 通知 */
.toast-container {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none; /* 允许下层交互 */
}
.toast {
  min-width: 240px;
  max-width: 360px;
  padding: 10px 14px;
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.12);
  background: #fff;
  border: 1px solid #e6e8eb;
  color: #222;
  font-size: 14px;
  opacity: 0;
  transform: translateX(16px);
  transition: opacity .25s ease, transform .25s ease;
}
.toast.show { opacity: 1; transform: translateX(0); }
.toast.hide { opacity: 0; transform: translateX(16px); }
.toast.success { border-color: #b2f2bb; background: #ebfbee; color: #0ca678; }
.toast.error { border-color: #ffc9c9; background: #fff5f5; color: #e03131; }
/* 进度选择器宽度（新建区域） */
#todo-progress { min-width: 170px; }